﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace Faust.Andrew.MTG.Player
{
	/// <summary>
	/// Interaction logic for NotificationControl.xaml
	/// </summary>
	public partial class NotificationControl : UserControl, INotificationView
	{

        static DependencyProperty PresenterProperty = DependencyProperty.Register("Presenter", typeof(GamePresenter), typeof(NotificationControl));
        public GamePresenter Presenter
        {
            get
            {
                return (GamePresenter)base.GetValue(PresenterProperty);
            }
            set
            {
                base.SetValue(PresenterProperty, value);
            }
        }

        static DependencyProperty EnableAutoScrollProperty = DependencyProperty.Register("EnableAutoScroll", typeof(bool), typeof(NotificationControl));
        public bool EnableAutoScroll
        {
            get
            {
                return (bool)base.GetValue(EnableAutoScrollProperty);
            }
            set
            {
                base.SetValue(EnableAutoScrollProperty, value);
            }
        }

		public NotificationControl()
		{
			this.InitializeComponent();
		}

        private List<int> GetSelectedPlayers()
        {
            List<int> players = new List<int>();

            foreach (PlayerState player in lbPlayers.SelectedItems)
            {
                players.Add(player.PlayerID);
            }

            return players;
        }

		private void btnSend_Click(object sender, System.Windows.RoutedEventArgs e)
		{
            if (Presenter.Model.SendMessage(txtMessage.Text, GetSelectedPlayers()))
            {
                txtMessage.Text = String.Empty;
            }
		}
	}
}